import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  HttpCode,
} from '@nestjs/common';
import { InterfacesService } from './interfaces.service';
import { CreateInterfaceDto } from './dto/create-interface.dto';
import { UpdateInterfaceDto } from './dto/update-interface.dto';
import { Auth } from '@/jwt/jwt.decorator';

@Controller('interfaces')
export class InterfacesController {
  constructor(private readonly interfacesService: InterfacesService) {}

  @Post()
  @Auth()
  @HttpCode(200)
  create(@Body() createInterfaceDto: CreateInterfaceDto) {
    return this.interfacesService.create(createInterfaceDto);
  }

  @Get('all/:directoryId')
  @Auth()
  @HttpCode(200)
  findAll(@Param('directoryId') directoryId: string) {
    return this.interfacesService.findAll(+directoryId);
  }

  @Get(':id')
  @Auth()
  findOne(@Param('id') id: string) {
    return this.interfacesService.findOne(+id);
  }

  @Patch(':id')
  @Auth()
  update(
    @Param('id') id: string,
    @Body() updateInterfaceDto: UpdateInterfaceDto,
  ) {
    return this.interfacesService.update(+id, updateInterfaceDto);
  }

  @Delete(':id')
  @Auth()
  remove(@Param('id') id: string) {
    return this.interfacesService.remove(+id);
  }
}
